package com.football.feign.controller;

import com.football.feign.entity.User;
import com.football.feign.service.UserFeignService;
import org.hxyjs.page.PageInfo;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
public class UserFeignController {
    @Resource
    UserFeignService userFeignService;

    @GetMapping("/users")

    public String getAllUsers() {
        return userFeignService.getAllUsers();
    }

    @RequestMapping(value = "/user/{uno}",method = RequestMethod.POST)


    public String getUserBySno(@PathVariable("uno") String uno) {
        return userFeignService.getUserByUno(uno);
    }

    @PatchMapping(value = "/user",headers = {"content-type=application/json"},consumes = MediaType.APPLICATION_JSON_VALUE
    )  //部分修改
    public String updateUser(@RequestBody User user){
        return userFeignService.updateUser(user);
    }

    @RequestMapping("/users/pageInfo")
    @ResponseBody
    public String getUsersByPage(@SpringQueryMap PageInfo pageInfo){
        return userFeignService.getUsersByPage(pageInfo);
    }
}
